home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Magnum One
/
Magnum One (Mid-American Digital) (Disc Manufacturing).iso
/
d20
/
dorskel2.arc
/
MTASK.C
< prev
next >
Wrap
C/C++ Source or Header
|
1991-12-05
|
3KB
|
145 lines
/**********************************************************/
/* Functions to help DOORSKEL get along with multitaskers */
/* and other mumbo-jumbo */
/**********************************************************/
#include "doorskel.h"
static union REGS rg;
static int mtask = 0; /* type of multitasker, if any */
#define DVID 1
#define DDOSID 2
#define MOSID 3
#define TVID 4
static int _fastcall is_dv (void);
static int _fastcall is_ddos (void);
static int _fastcall is_mos (void);
static int _fastcall is_tv (void);
static void _fastcall pause_dv (void);
static void _fastcall pause_ddos (void);
static void _fastcall pause_tv (void);
static void _fastcall pause_mos (void);
void _fastcall set_mtask (void) {
if(is_dv()) mtask=DVID;
else if(is_ddos()) mtask=DDOSID;
else if(is_mos()) mtask=MOSID;
else if(is_tv()) mtask=TVID;
}
static int _fastcall is_dv (void) {
rg.x.cx=0x04445;
rg.x.dx=0x05351;
rg.x.ax=0x02b01;
int86(0x21,&rg,&rg);
if(rg.h.al==0x0ff) return 0;
return rg.x.bx;
}
int _fastcall is_ddos (void) {
rg.h.ah=0x0e4;
int86(0x21,&rg,&rg);
if(rg.h.al==1 || rg.h.al==2) return 1;
return 0;
}
int _fastcall is_mos (void) {
int temp;
rg.h.ah=0x030;
int86(0x21,&rg,&rg);
temp=rg.x.ax;
rg.x.ax=0x03000;
rg.x.bx=0x03000;
rg.x.cx=0x03000;
rg.x.dx=0x03000;
int86(0x21,&rg,&rg);
if(rg.x.ax==temp) return temp;
return 0;
}
int _fastcall is_tv (void) {
rg.x.ax=0x01022;
rg.x.bx=0;
int86(0x15,&rg,&rg);
if(!rg.x.bx) return 0;
return rg.x.bx;
}
void _fastcall pause_dv (void) {
rg.x.ax = 0x0101a;
int86(0x15,&rg,&rg);
rg.x.ax = 0x01000;
int86(0x15,&rg,&rg);
rg.x.ax = 0x01025;
int86(0x15,&rg,&rg);
}
void _fastcall pause_ddos (void) {
int86(0xf4,&rg,&rg);
}
void _fastcall pause_tv (void) {
rg.x.ax = 0x01000;
int86(0x15,&rg,&rg);
}
void _fastcall pause_mos (void) {
rg.x.ax = 0x0703;
rg.x.bx = 0x03;
rg.x.cx = 0;
rg.x.dx = 0;
int86(0x38,&rg,&rg);
}
void _fastcall pause_mtask (void) {
switch(mtask) {
case 0: break;
case DVID: pause_dv();
break;
case DDOSID: pause_ddos();
break;
case TVID: pause_tv();
break;
case MOSID: pause_mos();
break;
}
int86(0x28,&rg,&rg); /* DOS scheduler interrupt */
}
void _fastcall my_sleep (int secs) { /* snooze a while */
clock_t t1;
t1 = clock() + ((clock_t)secs * (clock_t)CLOCKS_PER_SEC);
while(clock() < t1) pause_mtask();
}